﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.Core.Contents.Extensions;
using Orchard.Data.Migration;

namespace MediaGarden.Playlists
{
    public class Migrations : DataMigrationImpl
    {

        public int Create()
        {
            ContentDefinitionManager.AlterTypeDefinition("Playlist", cfg => cfg
                 .WithPart("CommonPart")
                 .WithPart("RoutePart")
                 .WithPart("MediaPart")
                 .WithPart("MediaLengthPart")
                 .WithPart("FileSizePart")
                 .WithPart("PixelDimensionsPart")
                 .WithSetting("Stereotype", "Content")
                 .WithSetting("MediaStereotype", "Playlist")
                 .WithSetting("TypeIndexing.Included", "true")
                 .Creatable()
                 .Draftable()
            );

            return 2;
        }
        public int UpdateFrom1()
        {
            ContentDefinitionManager.AlterTypeDefinition("PlaylistMedia", type => type
                .WithSetting("TypeIndexing.Included", "true"));
            return 2;
        }

    }
}